package com.study;
/*
二、编程题
1.定义一个int类型的变量,初始化值为1234,求这个数的个位,十位,百位,千位分别是多少?
运行效果:
 1234的个位是4,十位是3,百位是2,千位是1
（请提交代码并附上正确的运行截图）
* */
public class Demo1 {
    public static String getEveryNum(int number){
        int unit = number % 10;
        int tens = number / 10 % 10;
        int hundreds = number / 100 % 10;
        int thousands = number / 1000;
        return (
            number + "的个位是" + unit
            + ",十位是" + tens
            + ",百位是" + hundreds
            + ",千位是" + thousands
        );
    }
    public static void main(String[] args){
        String result = getEveryNum(1234);
        System.out.println(result);
    }
}
